package com.cbs.module.friend.entity;

import com.cbs.runtimecache.RuntimeCacheItem;
import com.google.gson.Gson;
import com.google.gson.reflect.TypeToken;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by broche on 1/11/16.
 */
public class FriendListCache extends RuntimeCacheItem {
    private Gson gson = new Gson();

    @Override
    public Object getDefaultValue() {
        return new ArrayList<FriendRelation>();
    }

    @Override
    public int getDataType() {
        return DataType_Object;
    }

    @Override
    public String encode(Object ovalue) {
        return gson.toJson(ovalue);
    }

    @Override
    public Object decode(String svalue) {
        return gson.fromJson(svalue, new TypeToken<List<FriendRelation>>() {
        }.getType());
    }

    @Override
    public boolean isSave() {
        return true;
    }

    @Override
    public boolean isNotify() {
        return false;
    }
}
